'use strict'

define(['jquery', 'bootstrap', 'select2', 'shiftform'], function($) {
  return {
    init : function(){
        
     this.initPage()
        
     this.delete()
      
    },
    
    initPage: function() {
        
        $('select[name="module"]').select2({
          minimumResultsForSearch : -1,
          allowClear : true,
          width: '120'
        });
        
        $('select[name="module"]').change(function(){
          
          var module = $(this).children('option:selected').val();
          
          if(module != '') {
        	  window.location.href = window.__CTX__.root + "/articles?moduleId=" + module;
          } else {
        	  window.location.href = window.__CTX__.root + "/articles";
          }
          
        })
        
      },
    
    delete : function() {
      $(document).on('shown.bs.modal', '#article-delete', function(e){
        $(e.currentTarget).find("form").shiftform()
      })
    }
  }
})

